#!/bin/bash
#PPPLHE copyright (c) 2010 Mohammed Shannaq
#www.irbidnet.com
#
#$Id: install_x3_branding.sh 25 2010-05-02 00:53:53Z m.shannaq $
#Rev: $Rev: 25 $

ROOT_UID=0
#errors
E_NOTROOT=67
E_WRONG_FOLDER=68
E_WRONG_DOWNLOADER=69
E_WRONG__WRONG_EXTRACTER=70

echo "PPPLHE: Predefined Procedures to Protect your Linux Hosting Environment"
echo "Copyright (c) 2010 Mohammed Shannaq"
echo "-----------------------------------------"
echo "modify cpanel x3 template to be more compatible with arabic"
echo "-----------------------------------------"
echo ""

#set -e

if [ "$UID" -ne "$ROOT_UID" ]
then
  echo "Must be root to run this script."
  exit $E_NOTROOT
fi

if [ ! -d /var/cpanel/userhomes/cpanel/cpanelbranding ]
then
  echo "ERROR:"
  echo "/var/cpanel/userhomes/cpanel/cpanelbranding folder not exists"
  echo "make sure this system use cpanel and use x3 template"
  exit $E_WRONG_FOLDER
fi	

wget http://ppplhe.googlecode.com/svn/trunk/LAMP/WHM/other/branding_x3_arabic_best_view/x3.tar.gz

if [ $? -ne 0 ]
then
  echo "ERROR:"
  echo "cannot download the template from ppplhe project, make sure from your connection or try again later"
  exit $E_WRONG_DOWNLOADER
fi

#install it
tar zxvf x3.tar.gz -C /var/cpanel/userhomes/cpanel/cpanelbranding/

if [ $? -ne 0 ]
then
  echo "ERROR:"
  echo "cannot extract downloaded file"
  exit $E_WRONG__WRONG_EXTRACTER
fi

rm -dfr x3.tar.gz

echo "+++++++++++++++++++++++++++++"
echo "++ Thank you               ++"
echo "++ the cpanel x3 template  ++"
echo "++ had been updated        ++"
echo "+++++++++++++++++++++++++++++"
echo "+++++++++++ OK ++++++++++++++"
echo "+++++++++++++++++++++++++++++"
